package cn.cy.controller;

import cn.cy.domain.DAO.Semester2step;
import cn.cy.domain.Point;
import cn.cy.domain.DTO.ResultDTO;
import cn.cy.domain.Image;
import cn.cy.domain.StepResult;
import cn.cy.service.FaceMatch;
import cn.cy.service.LowerComputer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Xucranger
 * @Date: 22/5/2 10:28
 */


@RestController
public class MatchController {

    @Autowired
    FaceMatch faceMatch;
    @Autowired
    LowerComputer lowerComputer;
    @Autowired
    Semester2step semester2step;

    @PostMapping("/matchface")
    public ResultDTO matchface(@RequestBody Image img1){

        return faceMatch.matchface(img1);
    }
    @PostMapping("/second/register")
    private ResultDTO register(){

        //将抽屉推入
        StepResult pushdraswer = lowerComputer.movedrawer(0);
        //获取学期
        String semester = "第一学年第一学期";
        Point point = semester2step.getByKey(semester);
        if(pushdraswer.getCode() == 200){
            StepResult arrive = lowerComputer.arriveto(point.getX(),point.getY());
            if(arrive.getCode() == 200){
                ResultDTO resultDTO = new ResultDTO("success");
                return resultDTO;
            }
            else {
                ResultDTO resultDTO = new ResultDTO("fail");
                return resultDTO;
            }
        }
        return new ResultDTO("fail");
    }
}
